package com.group.utils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * com.gxa.utils
 * User: 恩哲欣
 * Date: 2024/10/18 19:30
 * Motto: Where there is a will, there is a way!
 * Description:
 * Version: V1.0
 */
public class ResponseUtils {
    public static void responseToJson(HttpServletResponse httpServletResponse, String json) {
        try {
            // 告诉浏览器我先给你响应一个JSON类型的字符串
            httpServletResponse.setContentType("application/json;charset=utf-8");
            // 发送JSON
            httpServletResponse.getWriter().write(json);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage() + "JSON发送失败！");
        }
    }
}
